﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;

namespace SocketClient
{
    public class SocketClient
    {
        public static TcpClient client;
        public static bool isConnected = false;
        public static int ConnectServer()
        {
            try
            {
                client = new TcpClient();
                IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 3000);
                client.Connect(serverEndPoint);
                //SendToServer("request from client \r\n");
                isConnected = true;
                return 1;
            }
            catch (Exception ex)
            {
                return 0;
            }
        }
       /* public static int SendToServer(string message)
        {
            try
            {
                NetworkStream clientStream = client.GetStream();
                ASCIIEncoding encoder = new ASCIIEncoding();
                byte[] buffer = encoder.GetBytes(message);
                clientStream.Write(buffer, 0, buffer.Length);
                clientStream.Flush();
                return 1;
            }
            catch (Exception)
            {

                return 0;
            }
            
        }*/
    }
}
